cmake_minimum_required(VERSION 3.12)
project(service_client_server)

set(CMAKE_CXX_STANDARD 17)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(service_srv_interface REQUIRED)

set(
  THIS_PACKAGE_INCLUDE_DEPENDS
  rclcpp
  service_srv_interface
)
######################################topic pub#########################################
add_executable(service_client src/service_client.cpp )
target_include_directories(service_client PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${YAMLCPP_INCLUDE_DIRS}
)
ament_target_dependencies(service_client PUBLIC  ${THIS_PACKAGE_INCLUDE_DEPENDS})
install (
    TARGETS service_client
    ARCHIVE DESTINATION lib
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION lib/${PROJECT_NAME}
    )  
# Install libraries
install(
        TARGETS service_client
        EXPORT export_${PROJECT_NAME}
        ARCHIVE DESTINATION lib
        LIBRARY DESTINATION lib
        RUNTIME DESTINATION bin
        )
#######################################################################################

######################################topic sub#########################################
add_executable(service_server src/service_server.cpp )
target_include_directories(service_server PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${YAMLCPP_INCLUDE_DIRS}
)
ament_target_dependencies(service_server PUBLIC  ${THIS_PACKAGE_INCLUDE_DEPENDS})
install (
    TARGETS service_server
    ARCHIVE DESTINATION lib
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION lib/${PROJECT_NAME}
    )  
# Install libraries
install(
        TARGETS service_server
        EXPORT export_${PROJECT_NAME}
        ARCHIVE DESTINATION lib
        LIBRARY DESTINATION lib
        RUNTIME DESTINATION bin
        )
########################################################################################




install(
  DIRECTORY include
  DESTINATION include
)

install(
  DIRECTORY launch
  DESTINATION share/${PROJECT_NAME}
)

ament_export_include_directories(
  include
)
ament_export_libraries(
  ${PROJECT_NAME}
)
ament_export_targets(
  export_${PROJECT_NAME}
)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
ament_package()